<template>
  <div>
    <div class="nav"><bread-crumb></bread-crumb></div>
    <h1>期末成绩录入</h1>
    <div class="el_inp">
      <div class="inp">
        <el-form ref="form" :model="form" label-width="120px">
          <el-form-item label="学号" prop="stu_id">
            <el-input v-model.trim="form.stu_id"></el-input>
          </el-form-item>
          <el-form-item label="姓名" prop="stu_name">
            <el-input v-model.trim="form.stu_name"></el-input>
          </el-form-item>
          <el-form-item label="语文" prop="chinese">
            <el-input v-model.trim="form.chinese"></el-input>
          </el-form-item>
          <el-form-item label="数学" prop="math">
            <el-input v-model.trim="form.math"></el-input>
          </el-form-item>
          <el-form-item label="英语" prop="english">
            <el-input v-model.trim="form.english"></el-input>
          </el-form-item>
          <el-form-item label="理综" prop="lizong">
            <el-input v-model.trim="form.lizong"></el-input>
          </el-form-item>
          <el-form-item label="文宗" prop="wenzong">
            <el-input v-model.trim="form.wenzong"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="tijiao">提交</el-button>
            <el-button type="primary" @click="empty">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { Message } from "element-ui";
import { req_qimo_luru } from "../../../api/chengjixx";
export default {
  data() {
    return {
      form: {
        stu_id: "",
        stu_name: "",
        chinese: "",
        math: "",
        english: "",
        lizong: "",
        wenzong: "",
      },
    };
  },
  // async mounted() {
  //   let result = await req_ruxue();
  //   console.log(result);
  // },
  methods: {
    async tijiao() {
      let result = await req_qimo_luru(this.form);
      console.log(result);
      if (result.data == "成绩录入成功！！") {
        Message({
          type: "success",
          message: "提交成功",
        });
      } else {
        Message({
          type: "error",
          message: "学号重复，或网络不稳定，请重新提交",
        });
      }
    },
    empty() {
      console.log("重置");
      this.$refs.form.resetFields();
    },
  },
};
</script>

<style lang="scss" scoped>
h1 {
  text-align: center;
  padding: 20px;
}
.el_inp {
  display: flex;
  justify-content: center;
}
.inp {
  width: 350px;
}
</style>